
macro FastProcEnter a
{
   match any, a
   \{
      push a
      mov  a, esp
   \}
   match , a
   \{
      push ebp
      mov  ebp, esp
   \}
}

macro FastProcLeave a
{
   match any, a
   \{
      mov esp, a
      pop a
   \}
   match , a
   \{
      leave
   \}
}

macro AlignProcEnter a, b, s
{
   local loc,n,drap,sd
   n = 4
   sd = s

   drap equ a

   match =push d, a
   \{
      drap equ d
      n = 8
   \}
   match =pushn d, a
   \{
      drap equ d
      n = 8
      sd = 0
   \}

   if s
      if sd
	 loc = -4
      else
	 loc = 0
      end if
      if n = 8
	 push drap
      end if
      lea drap, [esp+n]
      and esp, -s
      push dword [drap-4]
   else
      loc = 0
   end if

   push ebp
   mov	ebp, esp

   if sd
      push drap
   end if
   irps c, b
   \{
      \forward
      push c
      loc = loc-4
   \}

   local_fp equ (ebp+loc)

   macro .rem@AlignProcLeave d
   \{
       match any, d \\{ r equ d \\}
       match , d \\{ r equ drap \\}

       if loc
	  lea esp, [ebp+loc]
	  irps c, b
	  \\{
	     \\reverse
	     pop c
	  \\}
	  if sd
	     pop r
	  end if

	  pop ebp
       else
	  leave
       end if

       if s
	  lea esp, [r-n]
	  if n = 8
	     pop drap
	  end if
       end if
   \}

   macro .base@AlignProcLeave d
   \{
       .rem@AlignProcLeave d
       restore drap
       restore r
   \}
}

macro AlignProcLeave a, b
{
   .base@AlignProcLeave a
   match , b \{
      restore local_fp
   \}
   purge .base@AlignProcLeave
}

macro ._until a, b
{
   dec	 a
   match any, b \{
      .until ZERO? & (b)
   \}
   match , b \{
      .until ZERO?
   \}
}

macro movstr r, s
{
   local   .a
   call    .a
   db	   s, 0
.a:
   pop	   r
}
